{# expects a 'sub' that is one datum from FormSubmissionFollowupListSerializer -#}
<tr class="form_submission" data-key="{{ sub.id }}">
  <td>
  {# ID #}
    <a href="{{ sub.url }}">{{ sub.id }}</a>
  </td>
  <td>
  {# Received #}
    <a href="{{ sub.url }}">
      <div class="date_received">
        <div class="date">{{ 
          sub.local_date_received.strftime('%b %-d')
        }}</div>
        <div class="time">{{ 
          sub.local_date_received.strftime('%-I:%M %p') 
        }}</div>
      </div>
    </a>
  </td>
  <td>
  {# Name #}
    {{ sub.full_name }}
  </td>
  <td>
  {# Contact #}
    <div class="phone_number">
      {%- if sub.phone_number %}
        +1{{ sub.phone_number }}
      {%- else %}
        -----
      {%- endif %}
    </div>
    <div class="email">
      {%- if sub.email %}
        {{ sub.email }}
      {%- else %}
        -----
      {%- endif %}
    </div>
  </td>
  <td class="org_tags">
  {# Applications & latest status #}
  <table>
    {%- for app in sub.applications %}
    <tr>
      <td class="org_tag">{{ app.organization }}</td>
      <td class="org_tag">
        {% if app.latest_status %}
          {{ app.latest_status.status_type }}
        {%- else -%}
          New
        {% endif %}
        <br/>
        {% if app.latest_status %}
          {{ humanize.naturaltime(app.latest_status.created) }}
        {% endif %}
      </td>
    </tr>
    {%- endfor %}
    </table>
  </td>
  {%- if perms.intake.add_applicationnote %}
  <td class="notes_log-cell">
  {# Notes #}
    <div class="notes_log">
      {%- if perms.intake.add_applicationnote %}
      <form class="note-create_form" action="{{ url('intake-create_note') }}" method="post">
        <input type="hidden" name="submission" value="{{ sub.id }}">
        <input type="hidden" name="user" value="{{ request.user.id }}">
        <input type="text" name="body"><button type="submit" class="btn btn-default btn-sm">
          <span class="glyphicon glyphicon-comment"></span>
          Save note
        </button>
      </form>
      {%- endif %}
      <div class="notes">
      {%- for note in sub.notes %}
        <div class="note" data-key="{{ note.id }}">
          <div class="note-time">{{
            note.created
          }}</div>
          <div class="note-body">{{ note.body }}</div>
          <div class="note-author">-{{ note.user }}</div>
          
          {%- if perms.intake.delete_applicationnote %}
          <div class="note-remove" title="Delete this note">
            <button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove-sign"></span>
             Delete</a>
          </div>
          {%- endif %}
        </div>
      {%- endfor %}
      </div>
    </div>
  </td>
  <td class="tags-cell">
  {# Tags #}
    <div class="tags-input_module">
      <div class="tags">
        {%- for tag in sub.tags %}
          <span class="tag label label-default" data-key="{{ tag.id }}">
            <span class="tag-text">{{ tag.name }}</span>
            <span class="tag-remove glyphicon glyphicon-remove-sign" title="Remove '{{ tag.name }}' tag"></span>
          </span>
        {%- endfor %}
      </div>
      <form class="tags-add_tags" action="/tags/add/" method="post">
        <input type="hidden" name="submission" value="{{ sub.id }}">
        <input type="hidden" name="user" value="{{ request.user.id }}">
        <input name="tags" type="text" autocomplete="off"><ul class="tags-autocomplete_results"></ul><button type="submit" class="btn btn-default btn-sm">
          <span class="glyphicon glyphicon-plus"></span>
          Add tags
        </button>
      </form>
    </div>
  </td>
  {%- endif %}
</tr>